package main

import "fmt"

func main() {
	numRows := 5
	fmt.Println(generate(numRows))
}

func generate(numRows int) [][]int {
	num := make([][]int, numRows)
	if numRows >= 1 {
		num[0] = make([]int, 1)
		num[0][0] = 1
	}
	if numRows >= 2 {
		num[1] = make([]int, 2)
		num[1][0], num[1][1] = 1, 1
	}

	for i := 2; i < numRows; i++ {
		num[i] = make([]int, i+1)
		num[i][0] = 1
		num[i][i] = 1
		for j := 1; j < i; j++ {
			num[i][j] = num[i-1][j-1] + num[i-1][j]
		}
	}

	return num
}
